﻿    $(document).ready(function () {
        $('#addcomments').bind('blur', function () {
            var line = "-------------------------------------------------------";
            var myDate = new Date();
            var myFormattedDate2 = myDate.f("dd/MM/yyyy HH:mm:ss");
            $("#DetailsView1_Comments").prepend($("#Header_lblUser").text() + ' -  ' + myFormattedDate2 + ' - ' + $('#addcomments').val() + '\n' + line + '\n');
        });
        $('#selcurrprovider').bind('change', function () {
            $("#DetailsView1_CurrentProvider").val($('#selcurrprovider').val());
        });
        $('#DetailsView1_selAdminFee').bind('onchange', function () {

            $("#DetailsView1_AdminFee").val($('#DetailsView1_selAdminFee').val());
        });

        if ($('#DetailsView1_lbluserID').text() == '') {
            $("#DetailsView1_UpdateButton").hide();
            $("#DetailsView1_DeleteButton").hide();

            if ($('#DetailsView1_AccountStatus').val() == '') {
                $("#DetailsView1_AccountStatus").val('0');
                $("#DetailsView1_StatusName").val('Status Not Set');
            }

            if ($("#Header_lblUser").text() == 'edia')
                $("#DetailsView1_OperatorSSE").val('Edia Fisher');
            if ($("#Header_lblUser").text() == 'omar')
                $("#DetailsView1_OperatorSSE").val('Omar Sabbagh');
            if ($("#Header_lblUser").text() == 'kelvin')
                $("#DetailsView1_OperatorSSE").val('Kelvin Wiggins');
            if ($("#Header_lblUser").text() == 'chuck')
                $("#DetailsView1_OperatorSSE").val('Chuck Robinson');
        }

        else {
            $("#DetailsView1_InsertButton").hide();
            $("#DetailsView1_CancelButton").hide();
        }

        if ($('#DetailsView1_TypeOrg').val() == 'RESI') {
            $("#DetailsView1_RESI_SME").val('RESI');
            $('#DetailsView1_CompanyName').hide();
            $('#DetailsView1_CompanyABN').hide();
            $('#DetailsView1_SecondAccountHolderTitle').hide();
            $('#DetailsView1_selSecondAccountHolderTitle').hide();
            $('#DetailsView1_SecondAccountHolderFirstName').hide();
            $('#DetailsView1_SecondAccountHolderSurname').hide();
            $('#DetailsView1_SecondAccountHolderDOB').hide();
            $('#DetailsView1_selConcessionCardType').hide();
            $('#DetailsView1_ConcessionCardType').hide();
            $('#DetailsView1_ConcessionCardEntitlement').hide();
            $('#DetailsView1_ConcessionCardNo').hide();
            $('#DetailsView1_ConcessionCardExp').hide();
            $('#DetailsView1_NameOnConcessionCard').hide();
            $('#DetailsView1_selSourceCodeSME').hide();
            $('#DetailsView1_selProductTypeSME').hide();
        }
        if (($('#DetailsView1_TypeOrg').val() == 'SME') || ($('#DetailsView1_TypeOrg').val() == 'C&I')) {
            $("#DetailsView1_RESI_SME").val('SME');
            $('#DetailsView1_ID_Type').hide();
            $('#DetailsView1_selID_Type').hide();
            $('#DetailsView1_ID_Number').hide();
            $('#DetailsView1_ID_Expiry').hide();
            $('#DetailsView1_FirstAccountHolderTitle').hide();
            $('#DetailsView1_selFirstAccountHolderTitle').hide();
            $('#DetailsView1_CopyName').hide();
            $('#DetailsView1_FirstAccountHolderFirstName').hide();
            $('#DetailsView1_FirstAccountHolderSurname').hide();
            $('#DetailsView1_FirstAccountHolderDOB').hide();
            $('#DetailsView1_selSecondAccountHolder').hide();
            $('#DetailsView1_SecondAccountHolderTitle').hide();
            $('#DetailsView1_selSecondAccountHolderTitle').hide();
            $('#DetailsView1_SecondAccountHolderFirstName').hide();
            $('#DetailsView1_SecondAccountHolderSurname').hide();
            $('#DetailsView1_SecondAccountHolderDOB').hide();
            $('#DetailsView1_selConcessionCard').hide();
            $('#DetailsView1_selConcessionCardType').hide();
            $('#DetailsView1_ConcessionCardType').hide();
            $('#DetailsView1_ConcessionCardEntitlement').hide();
            $('#DetailsView1_ConcessionCardNo').hide();
            $('#DetailsView1_ConcessionCardExp').hide();
            $('#DetailsView1_NameOnConcessionCard').hide();
            $('#DetailsView1_selSourceCodeRESI').hide();
            $('#DetailsView1_selProductTypeRESI').hide();

        }
        if ($("#Header_lblUser").text() == 'edia')
            $("#DetailsView1_OperatorSSE").val('Edia Fisher');
        if ($("#Header_lblUser").text() == 'omar')
            $("#DetailsView1_OperatorSSE").val('Omar Sabbagh');
        if ($("#Header_lblUser").text() == 'kelvin')
            $("#DetailsView1_OperatorSSE").val('Kelvin Wiggins');
        if ($("#Header_lblUser").text() == 'chuck')
            $("#DetailsView1_OperatorSSE").val('Chuck Robinson');

        if (($('#DetailsView1_ElectricityConversion').val() == 'NO') || ($('#DetailsView1_ElectricityConversion').val() == '')) {
            $("#DetailsView1_ElectricityConversion").val('NO');
            $("#DetailsView1_Elec").val('NO');
            $("#DetailsView1_ElecMonthQuarter").hide();
            $("#DetailsView1_selElecMonthQuarter").hide();
            $("#DetailsView1_ElecMonthQuarterSpend").hide();
            $("#DetailsView1_selElecSpend").hide();
            $("#DetailsView1_ElecTotalAnnualSpend").hide();
            $("#DetailsView1_NMI").hide();
        }

        if (($('#DetailsView1_GasConversion').val() == 'NO') || ($('#DetailsView1_GasConversion').val() == '')) {
            $("#DetailsView1_GasConversion").val('NO');
            $("#DetailsView1_Gas").val('NO');
            $("#DetailsView1_GasMonthQuarter").hide();
            $("#DetailsView1_selGasMonthQuarter").hide();
            $("#DetailsView1_GasMonthQuarterSpend").hide();
            $("#DetailsView1_selGasSpend").hide();
            $("#DetailsView1_GasTotalAnnualSpend").hide();
            $("#DetailsView1_MIRN").hide();
        }

        if ($('#DetailsView1_MoverSwicher').val() == 'Swicher')
            $('#DetailsView1_MoveInDate').hide();
    });

    function SecondAccountHolderChanged() {
        if ($("#DetailsView1_selSecondAccountHolder").val() == 'NO') {
            $('#DetailsView1_SecondAccountHolderTitle').hide();
            $('#DetailsView1_selSecondAccountHolderTitle').hide();
            $('#DetailsView1_SecondAccountHolderFirstName').hide();
            $('#DetailsView1_SecondAccountHolderSurname').hide();
            $('#DetailsView1_SecondAccountHolderDOB').hide();
        }
        if ($("#DetailsView1_selSecondAccountHolder").val() == 'YES') {
            $('#DetailsView1_SecondAccountHolderTitle').show();
            $('#DetailsView1_selSecondAccountHolderTitle').show();
            $('#DetailsView1_SecondAccountHolderFirstName').show();
            $('#DetailsView1_SecondAccountHolderSurname').show();
            $('#DetailsView1_SecondAccountHolderDOB').show();
        }
    }

    function ConcessionCardChanged() {
        if ($("#DetailsView1_selConcessionCard").val() == 'NO') {
            $('#DetailsView1_selConcessionCardType').hide();
            $('#DetailsView1_ConcessionCardType').hide();
            $('#DetailsView1_ConcessionCardEntitlement').hide();
            $('#DetailsView1_ConcessionCardNo').hide();
            $('#DetailsView1_ConcessionCardExp').hide();
            $('#DetailsView1_NameOnConcessionCard').hide();
        }
        if ($("#DetailsView1_selConcessionCard").val() == 'YES') {
            $('#DetailsView1_selConcessionCardType').show();
            $('#DetailsView1_ConcessionCardType').show();
            $('#DetailsView1_ConcessionCardEntitlement').show();
            $('#DetailsView1_ConcessionCardNo').show();
            $('#DetailsView1_ConcessionCardExp').show();
            $('#DetailsView1_NameOnConcessionCard').show();
        }
    }

    function CopyNameClick() {
        $("#DetailsView1_FirstAccountHolderFirstName").val($('#DetailsView1_FirstName').val());
        $("#DetailsView1_FirstAccountHolderSurname").val($('#DetailsView1_LastName').val());
    }
    function CopyAddressClick() {
        $("#DetailsView1_SupplyAddress").val($('#DetailsView1_Street').val());
        $("#DetailsView1_SupplyAddressSuburb").val($('#DetailsView1_Suburb').val());
        $("#DetailsView1_SupplyAddressState").val($('#DetailsView1_StateName').val());
        $("#DetailsView1_SupplyAddressPostcode").val($('#DetailsView1_Postcode').val());
    }
    function copybottonclick() {
        $("#DetailsView1_AccountHolderCompanyName").val($('#DetailsView1_CompanyName').val());
        $("#DetailsView1_FirstAccountHolderFirstName").val($('#DetailsView1_FirstName').val());
        $("#DetailsView1_FirstAccountHolderSurname").val($('#DetailsView1_LastName').val());
        $("#DetailsView1_ContactTel").val($('#DetailsView1_Phone').val());
        $("#DetailsView1_SecondTel").val($('#DetailsView1_Mobile').val());
        $("#DetailsView1_SupplyAddress").val($('#DetailsView1_Street').val());
        $("#DetailsView1_SupplyAddressSuburb").val($('#DetailsView1_Suburb').val());
        $("#DetailsView1_SupplyAddressState").val($('#DetailsView1_StateName').val());
        $("#DetailsView1_SupplyAddressPostcode").val($('#DetailsView1_Postcode').val());
    }

    function StateNameChanged() {
        $("#DetailsView1_StateName").val($('#DetailsView1_selStateName').val());
    }

    function PreferredTimeChanged() {
        $("#DetailsView1_PreferredTime").val($('#DetailsView1_selPreferredTime').val());
    }

    function PromotionCodeChanged() {
        $("#DetailsView1_PromotionCode").val($('#DetailsView1_selPromotionCode').val());
        if ($('#DetailsView1_PromotionCode').val() == '') {
            $("#DetailsView1_LeadSource").val('');
        }

	function PromotionCodeChanged() {
	    $("#DetailsView1_PromotionCode").val($('#DetailsView1_selPromotionCode').val());
	    if ($('#DetailsView1_PromotionCode').val() == '') {
	        $("#DetailsView1_LeadSource").val('');
	    }

	    if ($('#DetailsView1_PromotionCode').val() == 'DIRECT CUSTOMER') {
	        $("#DetailsView1_LeadSource").val('DIRECT CUSTOMER');
	    }
	    if ($('#DetailsView1_PromotionCode').val() == 'BALGOWLAH') {
	        $("#DetailsView1_LeadSource").val('BALGOWLAH');
	    }
	    if ($('#DetailsView1_PromotionCode').val() == 'CAMPAIGN 1') {
	        $("#DetailsView1_LeadSource").val('CAMPAIGN 1');
	    }
	    if ($('#DetailsView1_PromotionCode').val() == 'CAMPAIGN 2') {
	        $("#DetailsView1_LeadSource").val('CAMPAIGN 2');
	    }
	    if ($('#DetailsView1_PromotionCode').val() == 'CAMPAIGN 3') {
	        $("#DetailsView1_LeadSource").val('CAMPAIGN 3');
	    }
	    if ($('#DetailsView1_PromotionCode').val() == 'CO-OP BOOKSHOP') {
	        $("#DetailsView1_LeadSource").val('CO-OP BOOKSHOP');
	    }
	    if ($('#DetailsView1_PromotionCode').val() == 'CRICKET NSW') {
	        $("#DetailsView1_LeadSource").val('CRICKET NSW');
	    }
	    if ($('#DetailsView1_PromotionCode').val() == 'GEYER') {
	        $("#DetailsView1_LeadSource").val('GEYER');
	    }
	    if ($('#DetailsView1_PromotionCode').val() == 'GLEBE') {
	        $("#DetailsView1_LeadSource").val('GLEBE');
	    }
	    if ($('#DetailsView1_PromotionCode').val() == 'PETE EVANS') {
	        $("#DetailsView1_LeadSource").val('PETE EVANS');
	    }
	    if ($('#DetailsView1_PromotionCode').val() == 'PATHWAY') {
	        $("#DetailsView1_LeadSource").val('SSE QLD');
	    }
	    if ($('#DetailsView1_PromotionCode').val() == '2GB') {
	        $("#DetailsView1_LeadSource").val('2GB');
	    }
	    if ($('#DetailsView1_PromotionCode').val() == 'SEA EAGLES') {
	        $("#DetailsView1_LeadSource").val('SEA EAGLES');
	    }
	    if ($('#DetailsView1_PromotionCode').val() == 'SEA EAGLES B2B') {
	        $("#DetailsView1_LeadSource").val('SEA EAGLES');
	    }
	    if ($('#DetailsView1_PromotionCode').val() == 'SEAFORTH') {
	        $("#DetailsView1_LeadSource").val('SEAFORTH');
	    }
	    if ($('#DetailsView1_PromotionCode').val() == 'SUMO SALAD') {
	        $("#DetailsView1_LeadSource").val('SUMO SALAD');
	    }
	    if ($('#DetailsView1_PromotionCode').val() == 'TIN CAN BAY') {
            $("#DetailsView1_LeadSource").val('TIN CAN BAY');
	    }
        if ($('#DetailsView1_PromotionCode').val() == 'TYREPOWER') {
            $("#DetailsView1_LeadSource").val('TYREPOWER');
	    }
        if ($('#DetailsView1_PromotionCode').val() == 'TYRES & MORE') {
            $("#DetailsView1_LeadSource").val('TYRES & MORE');
	    }
        if ($('#DetailsView1_PromotionCode').val() == 'WPW') {
            $("#DetailsView1_LeadSource").val('WPW');
	    }
		if ($('#DetailsView1_PromotionCode').val() == 'NARRABEEN') {
            $("#DetailsView1_LeadSource").val('NARRABEEN');
	    }
		if ($('#DetailsView1_PromotionCode').val() == 'ERSKINEVILLE') {
            $("#DetailsView1_LeadSource").val('ERSKINEVILLE');
	    }
		if ($('#DetailsView1_PromotionCode').val() == 'LIVERPOOL') {
            $("#DetailsView1_LeadSource").val('LIVERPOOL');
	    }
		if ($('#DetailsView1_PromotionCode').val() == 'CHATSWOOD') {
            $("#DetailsView1_LeadSource").val('CHATSWOOD');
	    }
        if ($('#DetailsView1_PromotionCode').val() == 'CHILD CARE VIC') {
            $("#DetailsView1_LeadSource").val('CHILD CARE VIC');
        }
        if ($('#DetailsView1_PromotionCode').val() == 'JASON BASS') {
            $("#DetailsView1_LeadSource").val('JASON BASS');
        }
        if ($('#DetailsView1_PromotionCode').val() == 'RNNSW') {
            $("#DetailsView1_LeadSource").val('RNNSW');
        }
        if ($('#DetailsView1_PromotionCode').val() == 'LRNSW') {
            $("#DetailsView1_LeadSource").val('LRNSW');
        }
        if ($('#DetailsView1_PromotionCode').val() == 'TELEFIELD') {
            $("#DetailsView1_LeadSource").val('TELEFIELD');
        }
    }

    function CustomerTypeChanged() {
        $("#DetailsView1_CustomerType").val($('#DetailsView1_selCustomerType').val());
    }

    function LeadSourceChanged() {
        $("#DetailsView1_LeadSource").val($('#DetailsView1_selLeadSource').val());
    }

    function AdminFeeChanged() {
        $("#DetailsView1_AdminFee").val($('#DetailsView1_selAdminFee').val());
    }
    function AccountStatusChanged() {
        $("#DetailsView1_AccountStatus").val($('#DetailsView1_selAccountStatus').val());
        $("#DetailsView1_StatusName").val($('#DetailsView1_selAccountStatus').find(":selected").text());
        var myDate = new Date();
        var myFormattedDate1 = myDate.f("yyyy-MM-dd");
        var myFormattedDate2 = myDate.f("dd/MM/yyyy HH:mm:ss");
        var mytext = $('#DetailsView1_selAccountStatus').find(":selected").text()//$('#DetailsView1_selAccountStatus').text();
        $("#DetailsView1_AccountStatusHistory").prepend($("#Header_lblUser").text() + ' -  ' + myFormattedDate2 + ' - ' + mytext + '\n');
        if ($('#DetailsView1_selAccountStatus').val() == '9')
            $("#DetailsView1_DateConverted").val(myFormattedDate1);

    }

    function ProductNameChanged() {

        $("#DetailsView1_ProductNameID").val($('#DetailsView1_selProductName').val());
    }

    function TotalSitesChanged() {

        $("#DetailsView1_TotalSites").val($('#DetailsView1_selTotalSites').val());
    }

    function ElecMonthQuarterChanged() {
        $("#DetailsView1_ElecMonthQuarter").val($('#DetailsView1_selElecMonthQuarter').val());
    }

    function GasMonthQuarterChanged() {
        $("#DetailsView1_GasMonthQuarter").val($('#DetailsView1_selGasMonthQuarter').val());
    }

    function ElecSpendChanged() {
        $("#DetailsView1_ElecMonthQuarterSpend").val($('#DetailsView1_selElecSpend').val());
        var ElecMultiply = 0;
        if ($('#DetailsView1_selElecMonthQuarter').val() == 'Quarter') {
            ElecMultiply = 4;
        }
        if ($('#DetailsView1_selElecMonthQuarter').val() == 'Month') {
            ElecMultiply = 12;
        }
        var elecSpendvalue = $('#DetailsView1_selElecSpend').val() * ElecMultiply;
        var gasSpendvalue = $('#DetailsView1_GasTotalAnnualSpend').val() * 1;
        var total = elecSpendvalue + gasSpendvalue;
        $("#DetailsView1_ElecTotalAnnualSpend").val(elecSpendvalue);
        $("#DetailsView1_TotalAnnualSpend").val(total);
    }

    function GasSpendChanged() {
        $("#DetailsView1_GasMonthQuarterSpend").val($('#DetailsView1_selGasSpend').val());
        var GasMultiply = 0;
        if ($('#DetailsView1_selGasMonthQuarter').val() == 'Quarter') {
            GasMultiply = 4;
        }
        if ($('#DetailsView1_selGasMonthQuarter').val() == 'Month') {
            GasMultiply = 12;
        }
        var elecSpendvalue = $('#DetailsView1_ElecTotalAnnualSpend').val() * 1;
        var gasSpendvalue = $('#DetailsView1_selGasSpend').val() * GasMultiply;
        var total = elecSpendvalue + gasSpendvalue;
        $("#DetailsView1_GasTotalAnnualSpend").val(gasSpendvalue);
        $("#DetailsView1_TotalAnnualSpend").val(total);
    }

    function OperatorSSEChanged() {

        $("#DetailsView1_OperatorSSE").val($('#DetailsView1_selOperatorSSE').val());

        if ($('#DetailsView1_OperatorSSE').val() == 'Edia Fisher') {
            $("#DetailsView1_VendorID").val('STSM0001001-STSM001500');
        }
        else if ($('#DetailsView1_OperatorSSE').val() == 'Omar Sabbagh') {
            $("#DetailsView1_VendorID").val('STSM0001501-STSM0002000');
        }
        else if ($('#DetailsView1_OperatorSSE').val() == 'Kelvin Wiggins') {
            $("#DetailsView1_VendorID").val('STSM0004001-STSM0004500');
        }
        else {
            ;
        }
    }

    function VendorIDChanged() {

        $("#DetailsView1_VendorID").val($('#DetailsView1_selVendorID').val());

        if ($('#DetailsView1_VendorID').val() == 'STSM0001001-STSM001500') {
            $("#DetailsView1_OperatorSSE").val('Edia Fisher');
        }
        else if ($('#DetailsView1_VendorID').val() == 'STSM0001501-STSM0002000') {
            $("#DetailsView1_OperatorSSE").val('Omar Sabbagh');
        }
        else if ($('#DetailsView1_VendorID').val() == 'STSM0004001-STSM0004500') {
            $("#DetailsView1_OperatorSSE").val('Kelvin Wiggins');
        }
        else {
            ;
        }
    }

    function TypeOrgChanged() {

        $("#DetailsView1_TypeOrg").val($('#DetailsView1_selTypeOrg').val());
        if ($('#DetailsView1_selTypeOrg').val() == 'RESI') {
            $("#DetailsView1_RESI_SME").val('RESI');
            $('#DetailsView1_CompanyName').hide();
            $('#DetailsView1_CompanyABN').hide();
            $('#DetailsView1_ID_Type').show();
            $('#DetailsView1_selID_Type').show();
            $('#DetailsView1_ID_Number').show();
            $('#DetailsView1_ID_Expiry').show();
            $('#DetailsView1_CopyName').show();
            $('#DetailsView1_FirstAccountHolderTitle').show();
            $('#DetailsView1_selFirstAccountHolderTitle').show();
            $('#DetailsView1_FirstAccountHolderFirstName').show();
            $('#DetailsView1_FirstAccountHolderSurname').show();
            $('#DetailsView1_FirstAccountHolderDOB').show();
            $('#DetailsView1_selSecondAccountHolder').show();
            $('#DetailsView1_SecondAccountHolderTitle').hide();
            $('#DetailsView1_selSecondAccountHolderTitle').hide();
            $('#DetailsView1_SecondAccountHolderFirstName').hide();
            $('#DetailsView1_SecondAccountHolderSurname').hide();
            $('#DetailsView1_SecondAccountHolderDOB').hide();
            $('#DetailsView1_selConcessionCard').show();
            $('#DetailsView1_selConcessionCardType').hide();
            $('#DetailsView1_ConcessionCardType').hide();
            $('#DetailsView1_ConcessionCardEntitlement').hide();
            $('#DetailsView1_ConcessionCardNo').hide();
            $('#DetailsView1_ConcessionCardExp').hide();
            $('#DetailsView1_NameOnConcessionCard').hide();
            $('#DetailsView1_selSourceCodeSME').hide();
            $('#DetailsView1_selProductTypeSME').hide();
            $('#DetailsView1_selSourceCodeRESI').show();
            $('#DetailsView1_selProductTypeRESI').show();
        }
        if (($('#DetailsView1_selTypeOrg').val() == 'SME') || ($('#DetailsView1_selTypeOrg').val() == 'C&I')) {
            $("#DetailsView1_RESI_SME").val('SME');
            $('#DetailsView1_CompanyName').show();
            $('#DetailsView1_CompanyABN').show();
            $('#DetailsView1_ID_Type').hide();
            $('#DetailsView1_selID_Type').hide();
            $('#DetailsView1_ID_Number').hide();
            $('#DetailsView1_ID_Expiry').hide();
            $('#DetailsView1_CopyName').hide();
            $('#DetailsView1_FirstAccountHolderTitle').hide();
            $('#DetailsView1_selFirstAccountHolderTitle').hide();
            $('#DetailsView1_FirstAccountHolderFirstName').hide();
            $('#DetailsView1_FirstAccountHolderSurname').hide();
            $('#DetailsView1_FirstAccountHolderDOB').hide();
            $('#DetailsView1_selSecondAccountHolder').hide();
            $('#DetailsView1_SecondAccountHolderTitle').hide();
            $('#DetailsView1_selSecondAccountHolderTitle').hide();
            $('#DetailsView1_SecondAccountHolderFirstName').hide();
            $('#DetailsView1_SecondAccountHolderSurname').hide();
            $('#DetailsView1_SecondAccountHolderDOB').hide();
            $('#DetailsView1_selConcessionCard').hide();
            $('#DetailsView1_selConcessionCardType').hide();
            $('#DetailsView1_ConcessionCardType').hide();
            $('#DetailsView1_ConcessionCardEntitlement').hide();
            $('#DetailsView1_ConcessionCardNo').hide();
            $('#DetailsView1_ConcessionCardExp').hide();
            $('#DetailsView1_NameOnConcessionCard').hide();
            $('#DetailsView1_selSourceCodeRESI').hide();
            $('#DetailsView1_selProductTypeRESI').hide();
            $('#DetailsView1_selSourceCodeSME').show();
            $('#DetailsView1_selProductTypeSME').show();
        }
    }

    function SourceCodeChanged() {

        $("#DetailsView1_SourceCode").val($('#DetailsView1_selSourceCode').val());

    }

    function SourceCodeRESIChanged() {

        $("#DetailsView1_SourceCode").val($('#DetailsView1_selSourceCodeRESI').val());

    }

    function SourceCodeSMEChanged() {

        $("#DetailsView1_SourceCode").val($('#DetailsView1_selSourceCodeSME').val());

    }

    function MoverSwicherChanged() {

        $("#DetailsView1_MoverSwicher").val($('#DetailsView1_selMoverSwicher').val());
        if ($('#DetailsView1_selMoverSwicher').val() == 'Swicher')
            $('#DetailsView1_MoveInDate').hide();
        if ($('#DetailsView1_selMoverSwicher').val() == 'Mover')
            $('#DetailsView1_MoveInDate').show();
    }

    function RESI_SME_Changed() {

        $("#DetailsView1_RESI_SME").val($('#DetailsView1_selRESI_SME').val());
    }

    function ID_TypeChanged() {

        $("#DetailsView1_ID_Type").val($('#DetailsView1_selID_Type').val());
    }

    function ElectricityConversionChanged() {

        $("#DetailsView1_ElectricityConversion").val($('#DetailsView1_selElectricityConversion').val());
        if ($('#DetailsView1_selElectricityConversion').val() == 'YES') {
            $("#DetailsView1_Elec").val('YES');
            $("#DetailsView1_ElecMonthQuarter").show();
            $("#DetailsView1_selElecMonthQuarter").show();
            $("#DetailsView1_ElecMonthQuarterSpend").show();
            $("#DetailsView1_selElecSpend").show();
            $("#DetailsView1_ElecTotalAnnualSpend").show();
            $("#DetailsView1_NMI").show();
        }
        if ($('#DetailsView1_selElectricityConversion').val() == 'NO') {
            $("#DetailsView1_Elec").val('NO');
            $("#DetailsView1_ElecMonthQuarter").hide();
            $("#DetailsView1_selElecMonthQuarter").hide();
            $("#DetailsView1_ElecMonthQuarterSpend").hide();
            $("#DetailsView1_selElecSpend").hide();
            $("#DetailsView1_ElecTotalAnnualSpend").hide();
            $("#DetailsView1_NMI").hide();
        }
    }

    function GasConversionChanged() {

        $("#DetailsView1_GasConversion").val($('#DetailsView1_selGasConversion').val());
        if ($('#DetailsView1_selGasConversion').val() == 'YES') {
            $("#DetailsView1_Gas").val('YES');
            $("#DetailsView1_GasMonthQuarter").show();
            $("#DetailsView1_selGasMonthQuarter").show();
            $("#DetailsView1_GasMonthQuarterSpend").show();
            $("#DetailsView1_selGasSpend").show();
            $("#DetailsView1_GasTotalAnnualSpend").show();
            $("#DetailsView1_MIRN").show();
        }
        if ($('#DetailsView1_selGasConversion').val() == 'NO') {
            $("#DetailsView1_Gas").val('NO');
            $("#DetailsView1_GasMonthQuarter").hide();
            $("#DetailsView1_selGasMonthQuarter").hide();
            $("#DetailsView1_GasMonthQuarterSpend").hide();
            $("#DetailsView1_selGasSpend").hide();
            $("#DetailsView1_GasTotalAnnualSpend").hide();
            $("#DetailsView1_MIRN").hide();
        }
    }

    function ConcessionCardTypeChanged() {

        $("#DetailsView1_ConcessionCardType").val($('#DetailsView1_selConcessionCardType').val());
    }

    function FirstAccountHolderTitleChanged() {

        $("#DetailsView1_FirstAccountHolderTitle").val($('#DetailsView1_selFirstAccountHolderTitle').val());
    }

    function SecondAccountHolderTitleChanged() {

        $("#DetailsView1_SecondAccountHolderTitle").val($('#DetailsView1_selSecondAccountHolderTitle').val());
    }

    function TenantOwnerChanged() {

        $("#DetailsView1_TenantOwner").val($('#DetailsView1_selTenantOwner').val());
    }

    function SupplyAddressStateChanged() {

        $("#DetailsView1_SupplyAddressState").val($('#DetailsView1_selSupplyAddressState').val());
    }

    function ElecChanged() {

        $("#DetailsView1_Elec").val($('#DetailsView1_selElec').val());
    }

    function GasChanged() {

        $("#DetailsView1_Gas").val($('#DetailsView1_selGas').val());
    }

    function ProductTypeChanged() {

        $("#DetailsView1_ProductType").val($('#DetailsView1_selProductType').val());
    }

    function ProductTypeRESIChanged() {

        $("#DetailsView1_ProductType").val($('#DetailsView1_selProductTypeRESI').val());
    }

    function ProductTypeSMEChanged() {

        $("#DetailsView1_ProductType").val($('#DetailsView1_selProductTypeSME').val());
    }

    function NoOfPeopleInHouseChanged() {

        $("#DetailsView1_NoOfPeopleInHouse").val($('#DetailsView1_selNoOfPeopleInHouse').val());
    }

    function ElecStatusChanged() {

        $("#DetailsView1_ElecStatus").val($('#DetailsView1_selElecStatus').val());
    }

    function GasStatusChanged() {

        $("#DetailsView1_GasStatus").val($('#DetailsView1_selGasStatus').val());
    }

    function ReasonChanged() {

        $("#DetailsView1_Reason").val($('#DetailsView1_selReason').val());
    }

    function SafetyCertificateRequiredChanged() {

        $("#DetailsView1_SafetyCertificateRequired").val($('#DetailsView1_selSafetyCertificateRequired').val());
    }

    function AdvisedMainSwitchNeedsTurningOffChanged() {

        $("#DetailsView1_AdvisedMainSwitchNeedsTurningOff").val($('#DetailsView1_selAdvisedMainSwitchNeedsTurningOff').val());
    }

    function ExistingTRUEnergyCustomerChanged() {

        $("#DetailsView1_ExistingTRUEnergyCustomer").val($('#DetailsView1_selExistingTRUEnergyCustomer').val());
    }

    function AdditionalQuestionChanged() {

        $("#DetailsView1_AdditionalQuestion").val($('#DetailsView1_selAdditionalQuestion').val());
    }

    function checkbottonclick() {
        var string = "";

        if ($('#DetailsView1_FirstName').val() == '')
            string = string + "FirstName\n"
        if ($('#DetailsView1_LastName').val() == '')
            string = string + "LastName\n"
        if ($('#DetailsView1_Phone').val() == '')
            string = string + "Phone\n"
        if ($('#DetailsView1_Street').val() == '')
            string = string + "Street\n"
        if ($('#DetailsView1_Suburb').val() == '')
            string = string + "Suburb\n"
        if ($('#DetailsView1_StateName').val() == '')
            string = string + "StateName\n"
        if ($('#DetailsView1_Postcode').val() == '')
            string = string + "Postcode\n"

        if ($('#DetailsView1_PromotionCode').val() == '')
            string = string + "PromotionCode\n"
        if ($('#DetailsView1_LeadSource').val() == '')
            string = string + "LeadSource\n"
        if ($('#DetailsView1_CurrentProvider').val() == '')
            string = string + "CurrentProvider\n"
        if ($('#DetailsView1_TypeOrg').val() == '')
            string = string + "TypeOrg\n"
        if ($('#DetailsView1_TotalSites').val() == '')
            string = string + "TotalSites\n"
        if ($('#DetailsView1_StatusName').val() == '')
            string = string + "StatusName\n"


        if ($('#DetailsView1_DateConverted').val() == '')
            string = string + "DateConverted\n"
        if ($('#DetailsView1_OperatorSSE').val() == '')
            string = string + "OperatorSSE\n"
        if ($('#DetailsView1_VendorID').val() == '')
            string = string + "VendorID\n"
        if ($('#DetailsView1_SourceCode').val() == '')
            string = string + "SourceCode\n"
        if ($('#DetailsView1_RESI_SME').val() == '')
            string = string + "RESI_SME\n"
        if ($('#DetailsView1_MoverSwicher').val() == '')
            string = string + "MoverSwicher\n"
        if ($('#DetailsView1_ElectricityConversion').val() == '')
            string = string + "ElectricityConversion\n"
        if ($('#DetailsView1_GasConversion').val() == '')
            string = string + "GasConversion\n"
        if ($('#DetailsView1_ElecMonthQuarter').val() == '')
            string = string + "ElecMonthQuarter\n"
        if ($('#DetailsView1_ElecTotalAnnualSpend').val() == '')
            string = string + "ElecTotalAnnualSpend\n"
        if ($('#DetailsView1_TotalAnnualSpend').val() == '')
            string = string + "TotalAnnualSpend\n"
        if ($('#DetailsView1_FirstAccountHolderFirstName').val() == '')
            string = string + "FirstAccountHolderFirstName\n"
        if ($('#DetailsView1_FirstAccountHolderSurname').val() == '')
            string = string + "FirstAccountHolderSurname\n"
        if ($('#DetailsView1_FirstAccountHolderDOB').val() == '')
            string = string + "FirstAccountHolderDOB\n"
        if ($('#DetailsView1_ID_Type').val() == '')
            string = string + "ID_Type\n"
        if ($('#DetailsView1_ID_Number').val() == '')
            string = string + "ID_Number\n"
        if ($('#DetailsView1_ID_Expiry').val() == '')
            string = string + "ID_Expiry\n"
        if ($('#DetailsView1_ContactTel').val() == '')
            string = string + "ContactTel\n"
        if ($('#DetailsView1_Email').val() == '')
            string = string + "Email\n"
        if ($('#DetailsView1_SupplyAddress').val() == '')
            string = string + "SupplyAddress\n"
        if ($('#DetailsView1_SupplyAddressSuburb').val() == '')
            string = string + "SupplyAddressSuburb\n"
        if ($('#DetailsView1_ID_SupplyAddressState').val() == '')
            string = string + "SupplyAddressState\n"
        if ($('#DetailsView1_SupplyAddressPostcode').val() == '')
            string = string + "SupplyAddressPostcode\n"
        if ($('#DetailsView1_TenantOwner').val() == '')
            string = string + "TenantOwner\n"
        if ($('#DetailsView1_Elec').val() == '')
            string = string + "Elec\n"
        if ($('#DetailsView1_Gas').val() == '')
            string = string + "Gas\n"
        if ($('#DetailsView1_ProductType').val() == '')
            string = string + "ProductType\n"
        if ($('#DetailsView1_NMI').val() == '')
            string = string + "NMI\n"
        if ($('#DetailsView1_MIRN').val() == '')
            string = string + "MIRN\n"

        if (string == "")
            alert("All required fields has been filled!");
        else
            alert("The following fields:\n" + string + "Should be filled!");
    }